<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" >

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/turbolinks/5.2.0/turbolinks.js" integrity="sha256-iM4Yzi/zLj/IshPWMC1IluRxTtRjMqjPGd97TZ9yYpU=" crossorigin="anonymous"></script>
  <link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Cousine|Inconsolata" rel="stylesheet">
  <link rel="shortcut icon" type="image/png" href="/favicon.png">

  <link rel="stylesheet" href="/css/style.css">
  <link rel="stylesheet" href="/css/css/fontawesome-all.min.css">
  <link rel="stylesheet" href="/css/css/work-sans-v7.css">
  <script src="/js/main.js"></script>

  <!-- Begin Jekyll SEO tag v2.6.1 -->
<title>Understanding Transaction Status | Hive Developer</title>
<meta name="generator" content="Jekyll v4.0.0" />
<meta property="og:title" content="Understanding Transaction Status" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="How to use the Steem API to check the status of a transaction for a given trx_id value." />
<meta property="og:description" content="How to use the Steem API to check the status of a transaction for a given trx_id value." />
<link rel="canonical" href="understanding-transaction-status.html" />
<meta property="og:url" content="understanding-transaction-status.html" />
<meta property="og:site_name" content="Hive Developer" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2020-08-26T11:52:22-07:00" />
<script type="application/ld+json">
{"description":"How to use the Steem API to check the status of a transaction for a given trx_id value.","mainEntityOfPage":{"@type":"WebPage","@id":"understanding-transaction-status.html"},"@type":"BlogPosting","url":"understanding-transaction-status.html","headline":"Understanding Transaction Status","dateModified":"2020-08-26T11:52:22-07:00","datePublished":"2020-08-26T11:52:22-07:00","@context":"https://schema.org"}</script>
<!-- End Jekyll SEO tag -->


  
</head>
<body>
<header>
  <h1>
    <button type="button" class="open-nav" id="open-nav"></button>
    <a href="/"  class="logo-link"><img src="/images/logotype_black.svg" height="40" alt="Hive Developer logo"></a>
  </h1>

  
  <form action="/search/" method="get">
    <input type="text" name="q" id="search-input" placeholder="Search">
    <input type="submit" value="Search" style="display: none;">
  </form>
  

  <div id="sidebar" class="sidebar">
	
	
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/">
		<h6 class="ctrl-nav-section title">Introduction</h6>
		<ul class="cont-nav-section content">
			
				
					
					
						
						<li><a href="/#introduction-welcome">Welcome to Hive</a></li>
						
					
				
			
		</ul>
	</section>
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/quickstart/">
		<h6 class="ctrl-nav-section title">Quickstart</h6>
		<ul class="cont-nav-section content">
			
				
					
					
						
						<li><a href="/quickstart/#quickstart-choose-library">Choose Library</a></li>
						
					
						
						<li><a href="/quickstart/#quickstart-hive-full-nodes">Hive Nodes</a></li>
						
					
						
						<li><a href="/quickstart/#quickstart-testnet">Hive Testnet</a></li>
						
					
				
			
		</ul>
	</section>
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/tutorials/">
		<h6 class="ctrl-nav-section title">Tutorials</h6>
		<ul class="cont-nav-section content">
			
				
					
						<li><a href="/tutorials/#tutorials-javascript">Javascript</a></li>
					
				
					
						<li><a href="/tutorials/#tutorials-python">Python</a></li>
					
				
					
						<li><a href="/tutorials/#tutorials-ruby">Ruby</a></li>
					
				
					
						<li><a href="/tutorials/#tutorials-recipes">Recipes</a></li>
					
				
			
		</ul>
	</section>
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/services/">
		<h6 class="ctrl-nav-section title">Services</h6>
		<ul class="cont-nav-section content">
			
				
					
					
						
						<li><a href="/services/#services-hive-blog">hive.blog</a></li>
						
					
						
						<li><a href="/services/#services-hivesigner">HiveSigner</a></li>
						
					
						
						<li><a href="/services/#services-jussi">Jussi</a></li>
						
					
						
						<li><a href="/services/#services-imagehoster">ImageHoster</a></li>
						
					
						
						<li><a href="/services/#services-dhf">DHF</a></li>
						
					
				
			
		</ul>
	</section>
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/apidefinitions/">
		<h6 class="ctrl-nav-section title">Appbase API</h6>
		<ul class="cont-nav-section content">
			
				
					
					
						
						<li><a href="/apidefinitions/#apidefinitions-condenser-api">Condenser Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-bridge">Bridge</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-account-by-key-api">Account By Key Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-account-history-api">Account History Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-block-api">Block Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-database-api">Database Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-debug-node-api">Debug Node Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-follow-api">Follow Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-jsonrpc">Jsonrpc</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-market-history-api">Market History Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-network-broadcast-api">Network Broadcast Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-rc-api">Rc Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-reputation-api">Reputation Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-rewards-api">Rewards Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-tags-api">Tags Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-transaction-status-api">Transaction Status Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-witness-api">Witness Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-broadcast-ops">Broadcast Ops</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-broadcast-ops-communities">Broadcast Ops Communities</a></li>
						
					
				
			
		</ul>
	</section>
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/resources/">
		<h6 class="ctrl-nav-section title">Resources</h6>
		<ul class="cont-nav-section content">
			
				
					
					
						
						<li><a href="/resources/#resources-overview">Overview</a></li>
						
					
						
						<li><a href="/resources/#resources-client-libs">Client Libraries</a></li>
						
					
						
						<li><a href="/resources/#resources-bluepaper">Bluepaper</a></li>
						
					
						
						<li><a href="/resources/#resources-whitepaper">Whitepaper</a></li>
						
					
						
						<li><a href="/resources/#resources-tools">Tools</a></li>
						
					
						
						<li><a href="/resources/#resources-hivesigner-libs">Hivesigner Libs</a></li>
						
					
						
						<li><a href="/resources/#resources-hive-keychain">Hive Keychain</a></li>
						
					
						
						<li><a href="/resources/#resources-developeradvocate">Community & Help</a></li>
						
					
				
			
		</ul>
	</section>
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/glossary/">
		<h6 class="ctrl-nav-section title">Glossary</h6>
		<ul class="cont-nav-section content">
			
				
					
					
						
						<li><a href="/glossary/#glossary-chain-basics">Chain Basics</a></li>
						
					
						
					
						
						<li><a href="/glossary/#glossary-governance">Governance</a></li>
						
					
						
						<li><a href="/glossary/#glossary-transactions">Transactions</a></li>
						
					
						
						<li><a href="/glossary/#glossary-api">API</a></li>
						
					
						
						<li><a href="/glossary/#glossary-market">Market</a></li>
						
					
				
			
		</ul>
	</section>
	
</div>



  <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
</header>
<div class="main" id="top">
  <div class="hero">
    <h1 class="hero__h1">Hive Developer Portal </h1>
    <img class="hero__img" src="/images/honey-comb-92.png" style="position: relative; top: 10px;" />
  </div>
  <section id="tutorials-recipes-understanding-transaction-status" class="row tutorials-recipes-understanding-transaction-status">
	<h3>
		<a id="tutorials-recipes-understanding-transaction-status">
			Understanding Transaction Status
			
		</a>
	</h3>
	
		<span class="description"><p>How to use the Steem API to check the status of a transaction for a given <code class="highlighter-rouge">trx_id</code> value.</p>
</span>
	

	<p>The overarching goal is to stop using <a href="/apidefinitions/#condenser_api.broadcast_transaction_synchronous"><code class="highlighter-rouge">condenser_api.broadcast_transaction_synchronous</code></a> but we still want the benefits.</p>

<ul>
  <li><a href="#why-client-side-computation">Why Client-side Computation?</a></li>
  <li><a href="#why-after-broadcast">Why After Broadcast?</a></li>
  <li><a href="#why-in-general">Why In General?</a></li>
  <li><a href="#client-side-computation">Client-side Computation</a></li>
  <li><a href="#after-broadcast">After Broadcast</a></li>
  <li><a href="#polling">Polling</a></li>
</ul>

<h2 id="why-client-side-computation">Why Client-side Computation?</h2>

<p>The primary reason to compute the <code class="highlighter-rouge">trx_id</code> before broadcast is to track the transaction when quality of service is impacted. If the <code class="highlighter-rouge">trx_id</code> is known before <a href="/apidefinitions/#condenser_api.broadcast_transaction"><code class="highlighter-rouge">condenser_api.broadcast_transaction</code></a>, but the response times out, we can still track the transaction.</p>

<h2 id="why-after-broadcast">Why After Broadcast?</h2>

<p>Assuming quality of service has not been impacted, solely relying on the <a href="/apidefinitions/#condenser_api.broadcast_transaction"><code class="highlighter-rouge">condenser_api.broadcast_transaction</code></a> response should not be a problem.</p>

<h2 id="why-in-general">Why In General?</h2>

<p>Whichever method we use above to get <code class="highlighter-rouge">trx_id</code>, we can track it if anything goes wrong while we wait for it to be included in a block. Then, even after it’s included, we can still track a transaction while we wait for 2/3rds of the witnesses to verify (thus irreversable). We can poll <a href="/apidefinitions/#apidefinitions-transaction-status-api"><code class="highlighter-rouge">transaction_status_api</code></a> until we’re satisfied that the <code class="highlighter-rouge">trx_id</code> has been included.</p>
<h2 id="client-side-computation">Client-side Computation</h2>

<p>First, create a transaction, for example:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
   </span><span class="nl">"ref_block_num"</span><span class="p">:</span><span class="mi">20</span><span class="p">,</span><span class="w">
   </span><span class="nl">"ref_block_prefix"</span><span class="p">:</span><span class="mi">2890012981</span><span class="p">,</span><span class="w">
   </span><span class="nl">"expiration"</span><span class="p">:</span><span class="s2">"2018-10-15T19:52:09"</span><span class="p">,</span><span class="w">
   </span><span class="nl">"operations"</span><span class="p">:[</span><span class="w">
      </span><span class="p">{</span><span class="w">
         </span><span class="nl">"type"</span><span class="p">:</span><span class="s2">"transfer_to_vesting_operation"</span><span class="p">,</span><span class="w">
         </span><span class="nl">"value"</span><span class="p">:{</span><span class="w">
            </span><span class="nl">"from"</span><span class="p">:</span><span class="s2">"alice"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"to"</span><span class="p">:</span><span class="s2">"bob"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"amount"</span><span class="p">:{</span><span class="nl">"amount"</span><span class="p">:</span><span class="s2">"8204"</span><span class="p">,</span><span class="w"> </span><span class="nl">"precision"</span><span class="p">:</span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="nl">"nai"</span><span class="p">:</span><span class="s2">"@@000000021"</span><span class="p">}</span><span class="w">
         </span><span class="p">}</span><span class="w">
      </span><span class="p">}</span><span class="w">
   </span><span class="p">],</span><span class="w">
   </span><span class="nl">"extensions"</span><span class="p">:[]</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<p>From this, we create a serialization, call it <code class="highlighter-rouge">hex</code>:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1400351942ace9efc45b010305616c69636503626f620c2000000000000003535445454d00000
</code></pre></div></div>

<p>Next, we convert <code class="highlighter-rouge">hex</code> to binary, call it <code class="highlighter-rouge">bytes</code> and digest <code class="highlighter-rouge">bytes</code>, with sha256, call it <code class="highlighter-rouge">digest</code>:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>eba610257ad6c60d89f84ce54d3e10b52c18d4cce5547867e2450aeac80d9530
</code></pre></div></div>

<p>Last, we truncate <code class="highlighter-rouge">digest</code> to 20 bytes / 40 hex digits:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>eba610257ad6c60d89f84ce54d3e10b52c18d4cc
</code></pre></div></div>

<p>This is the computed <code class="highlighter-rouge">trx_id</code>.</p>

<h2 id="after-broadcast">After Broadcast</h2>

<p>If your client does not support client-side id computation, you can still get the <code class="highlighter-rouge">trx_id</code> from the result of <a href="/apidefinitions/#condenser_api.broadcast_transaction"><code class="highlighter-rouge">condenser_api.broadcast_transaction</code></a>.</p>

<p>The combination of <a href="/apidefinitions/#condenser_api.broadcast_transaction"><code class="highlighter-rouge">condenser_api.broadcast_transaction</code></a> and <a href="/apidefinitions/#transaction_status_api.find_transaction"><code class="highlighter-rouge">transaction_status_api.find_transaction</code></a>, described below, allows us to avoid using <a href="/apidefinitions/#condenser_api.broadcast_transaction_synchronous"><code class="highlighter-rouge">condenser_api.broadcast_transaction_synchronous</code></a>, which is being deprecated.</p>

<h2 id="polling">Polling</h2>

<p>Now that we have <code class="highlighter-rouge">trx_id</code>, we can poll <code class="highlighter-rouge">transaction_status_api.find_transaction</code>, for example:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>curl <span class="nt">-s</span> <span class="nt">--data</span> <span class="s1">'{"jsonrpc":"2.0", "method":"transaction_status_api.find_transaction", "params":{"transaction_id":"eba610257ad6c60d89f84ce54d3e10b52c18d4cc"}, "id":1}'</span> https://api.steemit.com
</code></pre></div></div>

<p>Which returns:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">{</span><span class="s2">"jsonrpc"</span>:<span class="s2">"2.0"</span>,<span class="s2">"result"</span>:<span class="o">{</span><span class="s2">"status"</span>:<span class="s2">"unknown"</span><span class="o">}</span>,<span class="s2">"id"</span>:1<span class="o">}</span>
</code></pre></div></div>

<p>We can provide the expiration:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>curl <span class="nt">-s</span> <span class="nt">--data</span> <span class="s1">'{"jsonrpc":"2.0", "method":"transaction_status_api.find_transaction", "params":{"transaction_id":"eba610257ad6c60d89f84ce54d3e10b52c18d4cc","expiration":"2018-10-15T19:52:09"}, "id":1}'</span> https://api.steemit.com
</code></pre></div></div>

<p>Which returns:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="nl">"jsonrpc"</span><span class="p">:</span><span class="s2">"2.0"</span><span class="p">,</span><span class="nl">"result"</span><span class="p">:{</span><span class="nl">"status"</span><span class="p">:</span><span class="s2">"too_old"</span><span class="p">},</span><span class="nl">"id"</span><span class="p">:</span><span class="mi">1</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<p>Possible <code class="highlighter-rouge">status</code> results are:</p>

<table>
  <thead>
    <tr>
      <th>Status</th>
      <th>Meaning</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="highlighter-rouge">unknown</code></td>
      <td>Expiration time in future, transaction not included in block or mempool</td>
    </tr>
    <tr>
      <td><code class="highlighter-rouge">within_mempool</code></td>
      <td>Transaction in mempool</td>
    </tr>
    <tr>
      <td><code class="highlighter-rouge">within_reversible_block</code></td>
      <td>Transaction has been included in block, block not irreversible (result will also contain <code class="highlighter-rouge">block_num</code>)</td>
    </tr>
    <tr>
      <td><code class="highlighter-rouge">within_irreversible_block</code></td>
      <td>Transaction has been included in block, block is irreversible (result will also contain <code class="highlighter-rouge">block_num</code>)</td>
    </tr>
    <tr>
      <td><code class="highlighter-rouge">expired_reversible</code></td>
      <td>Transaction has expired, transaction is not irreversible (transaction could be in a fork)</td>
    </tr>
    <tr>
      <td><code class="highlighter-rouge">expired_irreversible</code></td>
      <td>Transaction has expired, transaction is irreversible (transaction cannot be in a fork)</td>
    </tr>
    <tr>
      <td><code class="highlighter-rouge">too_old</code></td>
      <td>Transaction is too old, I don’t know about it</td>
    </tr>
  </tbody>
</table>

<p>See: <a href="/apidefinitions/#apidefinitions-transaction-status-api"><code class="highlighter-rouge">transaction_status_api</code></a></p>

</section>

</div>
<div class="footer">
  <a href="#">Back to top</a>
</div>
<script>
    document.getElementById("open-nav").addEventListener("click", function () {
        document.body.classList.toggle("nav-open");
    });
</script>
</body>
</html>


<script src="/js/adjust.js"></script>

